package org.linlinjava.litemall.web.controller;

import org.linlinjava.litemall.web.annotation.LogAnno;
import org.linlinjava.litemall.web.annotation.LoginShop;
import org.linlinjava.litemall.web.annotation.LoginUser;
import org.linlinjava.litemall.web.service.WebCloverPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * web三叶草支付控制器
 * clover支付
 *
 * @author yliyun
 * @date 2022/09/14
 */
@RestController
@RequestMapping("/web/cloverPay")
@Validated
public class WebCloverPayController {

    /**
     * 三叶草支付服务
     */
    @Autowired
    private WebCloverPayService cloverPayService;

    /**
     * 支付
     * clover支付记录 
     *
     * @param externalId 外部id
     * @param orderId    订单id
     * @param paymentId  支付id
     * @param cardNo     卡没有
     * @param cardType   卡类型
     * @param userId     用户id
     * @return 记录支付数据
     */
    @PostMapping("pay")
    @LogAnno
    public Object pay(@RequestParam String externalId,@RequestParam String orderId,@RequestParam String paymentId,String cardNo,String cardType,  @LoginUser Integer userId,@LoginShop Integer shopId) {
        return cloverPayService.cloverPay(externalId,orderId,paymentId,userId,cardNo,cardType,shopId);
    }


    /**
     * clover支付记录
     *
     * @param externalId 外部id
     * @param orderId    订单id
     * @param paymentId  支付id
     * @param userId     用户id
     * @param shopId     商店id
     * @return 记录支付数据
     */
    @PostMapping("cloverRefund")
    @LogAnno
    public Object cloverRefund(@RequestParam String externalId, @RequestParam String orderId,@RequestParam String paymentId, @LoginUser Integer userId, @LoginShop Integer shopId) {
        return cloverPayService.cloverRefund(externalId,orderId,paymentId,userId,shopId);
    }
}
